#!/usr/bin/env jruby

require 'test/unit'
dir = File.dirname(__FILE__)
require File.join(dir, '..', '..', 'lib', 'main', 'chartrans')

########################################

class TestCharTransIso2Ascii < Test::Unit::TestCase
  include CharTrans
  
  def test_should_translate_some_nonenglish_chars
    foreigns = {
      "ch\xE2teau" => 'chateau',
      "\xc9T\xc9"  => 'ETE',
      "\xEEle"     => 'ile',
      "H\xd4PITAL" => 'HOPITAL',
      "gef\xFClte" => 'gefulte',
      "I\xc7I"     => 'ICI',
      "ma\xF1ana"  => 'manana',
      "\xc6SOP"    => 'AESOP',
      "\x9Cdipus"  => 'oedipus',
      "MU\xdf"     => 'MUss',
    }
    foreigns.each { |k, v| assert_equal v, iso2ascii(k), k }
  end
  
  def test_should_translate_some_punctuation
    punctuateds = {
      "to\xADmorrow"  => "to-morrow",
      "Hallowe\x92en" => "Hallowe'en",
    }
    punctuateds.each { |k, v| assert_equal v, iso2ascii(k), k }
  end
  
  def test_should_leave_plain_english_alone
    borings = {
      "" => "",
      "foo BAR"    => "foo BAR",
      "to-morrow"  => "to-morrow",
      "Hallowe'en" => "Hallowe'en",
    }
    borings.each { |k, v| assert_equal v, iso2ascii(k), k }
  end
end
